package com.demo.service.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.github.pagehelper.PageHelper;

import com.generator.tools.text.Convert;
import com.demo.mapper.UserMapper;
import com.demo.service.IUserService;
import com.demo.entity.User;

import java.util.List;

/**
 * 
 *
 * @author blue demon
 * @date 2020/02/10
 */
@Service
public class UserServiceImpl implements IUserService {

	@Autowired
	private UserMapper userMapper;

	/**
	 * 通过Id查询 User
	 */
	@Override
	public User selectUserById(long userId) {
		return userMapper.selectUserById(userId);
	}

	/**
	 * 查询User列表
	 */

	@Override
  	public List<User> selectUserList(User user,int pageNum,int pageSize){
		return  PageHelper.startPage(pageNum,pageSize).doSelectPage(()->userMapper.selectUserList(user));
 	}

	/**
     * 新增User
     */
	@Override
	public int insertUser(User user) {
		return userMapper.insertUser(user);
	}

	/**
	 * 通过id删除User
	 */
	@Override
	public int deleteUserById(long userId) {
		return userMapper.deleteUserById(userId);
	}

	/**
	 * 通过id批量删除User
	 */
	@Override
	public int deleteUserByIds(String userIds){
		return userMapper.deleteUserByIds(Convert.toStrArray(userIds));
	 }

	/**
	 * 修改User信息
	 */
	@Override
	public int updateUser(User user) {
		return userMapper.updateUser(user);
	}

}